Print floating numbers upto 2 decimal placesΒΆ
Print the following floating numbers upto 2 decimal places.
x = 3.1415926
y = 12.9999
print("\nOriginal Number: ", x)
print("Formatted Number: "+"{:.2f}".format(x));
print("Original Number: ", y)
print("Formatted Number: "+"{:.2f}".format(y));
Output:
Original Number: 3.1415926
Formatted Number: 3.14
Original Number: 12.9999
Formatted Number: 13.00